'use strict';

const Controller = require('egg').Controller;

class LoginController extends Controller {
  async index() {
    const { ctx } = this;

    ctx.body = await ctx.renderView('login.html');
  }

  async vertify() {
    const { ctx } = this;
    const {name,password} = ctx.request.body;
    
    if(name === "admin" && password === '123456') {
      ctx.redirect(`/server`);
      
    }else {
      
      ctx.body = `hi, ${name}登陆失败`;
      ctx.redirect(`/login#failure`);
      // ctx.body = {
      //   success: true,
      //   message: '登陆失败',
      //   data: `hi, ${name}登陆失败`
      // };
    }
  }
}

module.exports = LoginController;